package com.luo.chengrui.module.sa.dal.mysql.person;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.sa.dal.dataobject.commontree.CommonTreeDO;
import com.luo.chengrui.module.sa.dal.dataobject.person.PersonDO;
import com.luo.chengrui.module.sa.dal.dataobject.person.PersonSyncDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.sa.controller.admin.person.vo.*;

/**
 * 人员  Mapper
 *
 * @author 诚睿
 */
@Mapper
public interface PersonMapper extends BaseMapperX<PersonDO> {

    default PageResult<PersonDO> selectPage(PersonPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PersonDO>()
                .eqIfPresent(PersonDO::getCode, reqVO.getCode())
                .likeIfPresent(PersonDO::getName, reqVO.getName())
                .eqIfPresent(PersonDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(PersonDO::getNum, reqVO.getNum())
                .likeIfPresent(PersonDO::getLoginName, reqVO.getLoginName())
                .eqIfPresent(PersonDO::getPassword, reqVO.getPassword())
                .eqIfPresent(PersonDO::getPasswordTimeLimit, reqVO.getPasswordTimeLimit())
                .betweenIfPresent(PersonDO::getPasswordModifyTime, reqVO.getPasswordModifyTime())
                .eqIfPresent(PersonDO::getMainOrgId, reqVO.getMainOrgId())
                .eqIfPresent(PersonDO::getSafeLevelId, reqVO.getSafeLevelId())
                .eqIfPresent(PersonDO::getSequence, reqVO.getSequence())
                .eqIfPresent(PersonDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PersonDO::getDescription, reqVO.getDescription())
                .eqIfPresent(PersonDO::getSex, reqVO.getSex())
                .eqIfPresent(PersonDO::getBirthday, reqVO.getBirthday())
                .betweenIfPresent(PersonDO::getJoinDate, reqVO.getJoinDate())
                .eqIfPresent(PersonDO::getHomePlace, reqVO.getHomePlace())
                .eqIfPresent(PersonDO::getDegree, reqVO.getDegree())
                .eqIfPresent(PersonDO::getGraduateSchool, reqVO.getGraduateSchool())
                .eqIfPresent(PersonDO::getSpeciality, reqVO.getSpeciality())
                .eqIfPresent(PersonDO::getSchoolLength, reqVO.getSchoolLength())
                .eqIfPresent(PersonDO::getTitle, reqVO.getTitle())
                .eqIfPresent(PersonDO::getMarriage, reqVO.getMarriage())
                .eqIfPresent(PersonDO::getCardNo, reqVO.getCardNo())
                .eqIfPresent(PersonDO::getCardKind, reqVO.getCardKind())
                .eqIfPresent(PersonDO::getFamilyAddress, reqVO.getFamilyAddress())
                .eqIfPresent(PersonDO::getZip, reqVO.getZip())
                .eqIfPresent(PersonDO::getMsn, reqVO.getMsn())
                .eqIfPresent(PersonDO::getQq, reqVO.getQq())
                .eqIfPresent(PersonDO::getEmail, reqVO.getEmail())
                .eqIfPresent(PersonDO::getMobilePhone, reqVO.getMobilePhone())
                .eqIfPresent(PersonDO::getFamilyPhone, reqVO.getFamilyPhone())
                .eqIfPresent(PersonDO::getOfficePhone, reqVO.getOfficePhone())
                .eqIfPresent(PersonDO::getVersion, reqVO.getVersion())
                .eqIfPresent(PersonDO::getPhotoFileId, reqVO.getPhotoFileId())
                .eqIfPresent(PersonDO::getCountry, reqVO.getCountry())
                .eqIfPresent(PersonDO::getProvince, reqVO.getProvince())
                .eqIfPresent(PersonDO::getCity, reqVO.getCity())
                .likeIfPresent(PersonDO::getEnglishName, reqVO.getEnglishName())
                .eqIfPresent(PersonDO::getPayPassword, reqVO.getPayPassword())
                .eqIfPresent(PersonDO::getIsOperator, reqVO.getIsOperator())
                .eqIfPresent(PersonDO::getIsHidden, reqVO.getIsHidden())
                .eqIfPresent(PersonDO::getAppCode, reqVO.getAppCode())
                .eqIfPresent(PersonDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(PersonDO::getMailPassword, reqVO.getMailPassword())
                .betweenIfPresent(PersonDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PersonDO::getId));
    }

    default List<PersonDO> selectList(PersonExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PersonDO>()
                .eqIfPresent(PersonDO::getCode, reqVO.getCode())
                .likeIfPresent(PersonDO::getName, reqVO.getName())
                .eqIfPresent(PersonDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(PersonDO::getNum, reqVO.getNum())
                .likeIfPresent(PersonDO::getLoginName, reqVO.getLoginName())
                .eqIfPresent(PersonDO::getPassword, reqVO.getPassword())
                .eqIfPresent(PersonDO::getPasswordTimeLimit, reqVO.getPasswordTimeLimit())
                .betweenIfPresent(PersonDO::getPasswordModifyTime, reqVO.getPasswordModifyTime())
                .eqIfPresent(PersonDO::getMainOrgId, reqVO.getMainOrgId())
                .eqIfPresent(PersonDO::getSafeLevelId, reqVO.getSafeLevelId())
                .eqIfPresent(PersonDO::getSequence, reqVO.getSequence())
                .eqIfPresent(PersonDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PersonDO::getDescription, reqVO.getDescription())
                .eqIfPresent(PersonDO::getSex, reqVO.getSex())
                .eqIfPresent(PersonDO::getBirthday, reqVO.getBirthday())
                .betweenIfPresent(PersonDO::getJoinDate, reqVO.getJoinDate())
                .eqIfPresent(PersonDO::getHomePlace, reqVO.getHomePlace())
                .eqIfPresent(PersonDO::getDegree, reqVO.getDegree())
                .eqIfPresent(PersonDO::getGraduateSchool, reqVO.getGraduateSchool())
                .eqIfPresent(PersonDO::getSpeciality, reqVO.getSpeciality())
                .eqIfPresent(PersonDO::getSchoolLength, reqVO.getSchoolLength())
                .eqIfPresent(PersonDO::getTitle, reqVO.getTitle())
                .eqIfPresent(PersonDO::getMarriage, reqVO.getMarriage())
                .eqIfPresent(PersonDO::getCardNo, reqVO.getCardNo())
                .eqIfPresent(PersonDO::getCardKind, reqVO.getCardKind())
                .eqIfPresent(PersonDO::getFamilyAddress, reqVO.getFamilyAddress())
                .eqIfPresent(PersonDO::getZip, reqVO.getZip())
                .eqIfPresent(PersonDO::getMsn, reqVO.getMsn())
                .eqIfPresent(PersonDO::getQq, reqVO.getQq())
                .eqIfPresent(PersonDO::getEmail, reqVO.getEmail())
                .eqIfPresent(PersonDO::getMobilePhone, reqVO.getMobilePhone())
                .eqIfPresent(PersonDO::getFamilyPhone, reqVO.getFamilyPhone())
                .eqIfPresent(PersonDO::getOfficePhone, reqVO.getOfficePhone())
                .eqIfPresent(PersonDO::getVersion, reqVO.getVersion())
                .eqIfPresent(PersonDO::getPhotoFileId, reqVO.getPhotoFileId())
                .eqIfPresent(PersonDO::getCountry, reqVO.getCountry())
                .eqIfPresent(PersonDO::getProvince, reqVO.getProvince())
                .eqIfPresent(PersonDO::getCity, reqVO.getCity())
                .likeIfPresent(PersonDO::getEnglishName, reqVO.getEnglishName())
                .eqIfPresent(PersonDO::getPayPassword, reqVO.getPayPassword())
                .eqIfPresent(PersonDO::getIsOperator, reqVO.getIsOperator())
                .eqIfPresent(PersonDO::getIsHidden, reqVO.getIsHidden())
                .eqIfPresent(PersonDO::getAppCode, reqVO.getAppCode())
                .eqIfPresent(PersonDO::getAvatar, reqVO.getAvatar())
                .eqIfPresent(PersonDO::getMailPassword, reqVO.getMailPassword())
                .eqIfPresent(PersonDO::getSystemUserId, reqVO.getSystemUserId())
                .orderByDesc(PersonDO::getId));
    }

    List<PersonSyncDO> selectSyncList();

    default PersonDO selectOne(PersonBaseVO reqVO) {
        LambdaQueryWrapperX<PersonDO> queryWrapper = new LambdaQueryWrapperX<PersonDO>()
                .eqIfPresent(PersonDO::getCode, reqVO.getCode())
                .likeIfPresent(PersonDO::getName, reqVO.getName())
                .eqIfPresent(PersonDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(PersonDO::getNum, reqVO.getNum())
                .likeIfPresent(PersonDO::getLoginName, reqVO.getLoginName())
                .eqIfPresent(PersonDO::getMainOrgId, reqVO.getMainOrgId())
                .eqIfPresent(PersonDO::getSafeLevelId, reqVO.getSafeLevelId())
                .eqIfPresent(PersonDO::getSequence, reqVO.getSequence())
                .eqIfPresent(PersonDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PersonDO::getDescription, reqVO.getDescription())
                .eqIfPresent(PersonDO::getSex, reqVO.getSex())
                .eqIfPresent(PersonDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(PersonDO::getHomePlace, reqVO.getHomePlace())
                .eqIfPresent(PersonDO::getDegree, reqVO.getDegree())
                .eqIfPresent(PersonDO::getGraduateSchool, reqVO.getGraduateSchool())
                .eqIfPresent(PersonDO::getSpeciality, reqVO.getSpeciality())
                .eqIfPresent(PersonDO::getSchoolLength, reqVO.getSchoolLength())
                .eqIfPresent(PersonDO::getTitle, reqVO.getTitle())
                .eqIfPresent(PersonDO::getMarriage, reqVO.getMarriage())
                .eqIfPresent(PersonDO::getCardNo, reqVO.getCardNo())
                .eqIfPresent(PersonDO::getCardKind, reqVO.getCardKind())
                .eqIfPresent(PersonDO::getFamilyAddress, reqVO.getFamilyAddress())
                .eqIfPresent(PersonDO::getZip, reqVO.getZip())
                .eqIfPresent(PersonDO::getMsn, reqVO.getMsn())
                .eqIfPresent(PersonDO::getQq, reqVO.getQq())
                .eqIfPresent(PersonDO::getEmail, reqVO.getEmail())
                .eqIfPresent(PersonDO::getMobilePhone, reqVO.getMobilePhone())
                .eqIfPresent(PersonDO::getFamilyPhone, reqVO.getFamilyPhone())
                .eqIfPresent(PersonDO::getOfficePhone, reqVO.getOfficePhone())
                .eqIfPresent(PersonDO::getVersion, reqVO.getVersion())
                .eqIfPresent(PersonDO::getPhotoFileId, reqVO.getPhotoFileId())
                .eqIfPresent(PersonDO::getCountry, reqVO.getCountry())
                .eqIfPresent(PersonDO::getProvince, reqVO.getProvince())
                .eqIfPresent(PersonDO::getCity, reqVO.getCity())
                .likeIfPresent(PersonDO::getEnglishName, reqVO.getEnglishName())
                .eqIfPresent(PersonDO::getPayPassword, reqVO.getPayPassword())
                .eqIfPresent(PersonDO::getIsOperator, reqVO.getIsOperator())
                .eqIfPresent(PersonDO::getIsHidden, reqVO.getIsHidden())
                .eqIfPresent(PersonDO::getAppCode, reqVO.getAppCode())
                .eqIfPresent(PersonDO::getSystemUserId, reqVO.getSystemUserId())
                .eqIfPresent(PersonDO::getMailPassword, reqVO.getMailPassword());

        return selectOne(queryWrapper);
    }

    List<String> getPersonFullIdsBySystemUserId(Long systemUserId);
}
